package com.coder.books.thinkinjava.enumerated;

import java.util.Date;

/**
 * 常量方法
 *
 * @author yuhushuan
 * @date 2020/8/30 09:30
 */
public enum ConstantSpecificMethod {
    DATE_TIME {
        @Override
        String getInfo() {
            return new Date().toString();
        }
    },
    CLASSPATH {
        @Override
        String getInfo() {
            return System.getenv("CLASSPATH");
        }
    },
    VERSION {
        @Override
        String getInfo() {
            if (version == null) {
                version = System.getProperty("java.version");
            }
            return version;
        }

        public String behavior(){
            return "behavior";
        }

        @Override
        public void check() {
            super.check();
        }
    };

    String version;

    abstract String getInfo();

    public void check(){

    }

    public static void main(String[] args) {
        System.out.println(DATE_TIME.getInfo());
        System.out.println(CLASSPATH.getInfo());
        System.out.println(VERSION.getInfo());
        VERSION.check();
        DATE_TIME.check();
    }
}
